package cn.liyicun.cp.cpweb.mapper;

import cn.liyicun.cp.cpweb.entity.AdminInfo;
import cn.liyicun.cp.cpweb.entity.AdminInfoExample;
import java.io.Serializable;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.session.RowBounds;
import org.apache.ibatis.type.JdbcType;

@Mapper
public interface AdminInfoMapper extends Serializable {
    @SelectProvider(type=AdminInfoSqlProvider.class, method="countByExample")
    long countByExample(AdminInfoExample example);

    @DeleteProvider(type=AdminInfoSqlProvider.class, method="deleteByExample")
    int deleteByExample(AdminInfoExample example);

    @Delete({
        "delete from admin_info",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long id);

    @Insert({
        "insert into admin_info (email, passwd, ",
        "create_time, status)",
        "values (#{email,jdbcType=VARCHAR}, #{passwd,jdbcType=VARCHAR}, ",
        "#{createTime,jdbcType=TIMESTAMP}, #{status,jdbcType=INTEGER})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Long.class)
    int insert(AdminInfo record);

    @InsertProvider(type=AdminInfoSqlProvider.class, method="insertSelective")
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Long.class)
    int insertSelective(AdminInfo record);

    @SelectProvider(type=AdminInfoSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="email", property="email", jdbcType=JdbcType.VARCHAR),
        @Result(column="passwd", property="passwd", jdbcType=JdbcType.VARCHAR),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="status", property="status", jdbcType=JdbcType.INTEGER)
    })
    List<AdminInfo> selectByExampleWithRowbounds(AdminInfoExample example, RowBounds rowBounds);

    @SelectProvider(type=AdminInfoSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="email", property="email", jdbcType=JdbcType.VARCHAR),
        @Result(column="passwd", property="passwd", jdbcType=JdbcType.VARCHAR),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="status", property="status", jdbcType=JdbcType.INTEGER)
    })
    List<AdminInfo> selectByExample(AdminInfoExample example);

    @Select({
        "select",
        "id, email, passwd, create_time, status",
        "from admin_info",
        "where id = #{id,jdbcType=BIGINT}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="email", property="email", jdbcType=JdbcType.VARCHAR),
        @Result(column="passwd", property="passwd", jdbcType=JdbcType.VARCHAR),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="status", property="status", jdbcType=JdbcType.INTEGER)
    })
    AdminInfo selectByPrimaryKey(Long id);

    @UpdateProvider(type=AdminInfoSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") AdminInfo record, @Param("example") AdminInfoExample example);

    @UpdateProvider(type=AdminInfoSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") AdminInfo record, @Param("example") AdminInfoExample example);

    @UpdateProvider(type=AdminInfoSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(AdminInfo record);

    @Update({
        "update admin_info",
        "set email = #{email,jdbcType=VARCHAR},",
          "passwd = #{passwd,jdbcType=VARCHAR},",
          "create_time = #{createTime,jdbcType=TIMESTAMP},",
          "status = #{status,jdbcType=INTEGER}",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(AdminInfo record);
}